<template>
  <div class="product">
    <h3>标题：{{ uname }}</h3>
    <p>价格:{{ proprice }}元一根</p>
    <p>描述:{{ desc }} <button @click="bargain">砍一刀</button> </p>
  </div>
</template>

<script>
export default {
  // 这里的name 和 注册的名字要统一，推荐使用大驼峰
  name: 'MyProduct',

  props: ['uname','proprice','desc','id'],

  data() {
    return {

    }
  },

  methods: {
    bargain() {
      this.$emit('sayPrice',10, this.id )
    }
  }

}
</script>

<style lang="less" scoped>
.product {
  width: 400px;
  border: 3px solid #000;
  border-radius: 5px;
  margin: 10px;
  padding: 0 20px;
}
</style>